﻿#include <stdio.h>
#include "L5_Graph.h"
#include "L5_Search.h"

int main ()
{
  L5_Graph 	Graph;
  L5_Search Search;

  //读取图(插入顶点）
  Graph.InsertVertex(1);
  Graph.InsertVertex(2);
  Graph.InsertVertex(3);
  Graph.InsertVertex(4);
  Graph.InsertVertex(5);
  Graph.InsertVertex(6);
  Graph.InsertVertex(7);
  Graph.InsertVertex(8);
  Graph.InsertVertex(9);
  //读取图（插入边）
  Graph.InsertEdge(1,6,1);
  Graph.InsertEdge(1,2,2);
  Graph.InsertEdge(3,6,3);
  Graph.InsertEdge(7,8,4);
  Graph.InsertEdge(7,9,5);
  Graph.InsertEdge(6,9,6);
  Graph.InsertEdge(5,8,7);
  Graph.InsertEdge(4,8,8);
  Graph.InsertEdge(8,9,9);
  Graph.InsertEdge(1,5,10);

//Q1 START
  Graph.printMatrixA();         //打印关联矩阵
  Graph.printMatrixX();         //打印邻接矩阵
  Graph.printMatrixC();         //打印全连通矩阵
  //补充
//Q1 END

//Q2 START
  Search.DFS_init(Graph.MatrixX, Graph.vertex, 1 );
  cout << endl << "======================" << endl;
  Search.BFS_init(Graph.MatrixX, Graph.vertex, 1 );
//Q2 END

  cout << "=======3333333333333333333333333333333333333333333333333333333333333333======" << endl;

//Q3 START
  Graph.DeleteVertex(9);
  Graph.DeleteEdge(1, 5, 10);
  Graph.printMatrixA();         //打印关联矩阵
  Graph.printMatrixX();         //打印邻接矩阵
  Graph.printMatrixC();         //打印全连通矩阵
  Search.DFS_init(Graph.MatrixX, Graph.vertex, 1 );
  cout << endl << "======================" << endl;
  Search.BFS_init(Graph.MatrixX, Graph.vertex, 1 );
//Q3 END

  cout << "=====444444444444444444444444444444444444444444444444444444444444444=====" << endl;

//Q4 START
  Graph.InsertVertex(9);
  Graph.InsertEdge(6, 9, 6);
  Graph.InsertEdge(7, 9, 5);
  Graph.InsertEdge(8, 9, 9);
  Graph.InsertEdge(1, 5, 10);
  Graph.InsertEdge(2, 4, 11);
  Graph.printMatrixA();         //打印关联矩阵
  Graph.printMatrixX();         //打印邻接矩阵
  Graph.printMatrixC();         //打印全连通矩阵
  Search.DFS_init(Graph.MatrixX, Graph.vertex, 1 );
  cout << endl << "======================" << endl;
  Search.BFS_init(Graph.MatrixX, Graph.vertex, 1 );

//Q4 END

  return 0;
}

